#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

typedef __int128 LLL;

const LL inf = 2e9;

unordered_map<LL, int> mp;

inline int sgn(LLL x)
{
	return (x > 0) - (x < 0);
}

LL sqrti(LLL x)
{
	LL y = sqrtl((long double)x);
	while ((y + 1) * (y + 1) <= x)
		++y;
	return y;
}


struct Eq3
{
	LLL a, b, c, d;
	Eq3(LLL a = 0, LLL b = 0, LLL c = 0, LLL d = 0)
		: a(a), b(b), c(c), d(d)
	{
	}

	LLL eval(LLL x)
	{
		return ((a * x + b) * x + c) * x + d;
	}

} e;

inline bool inbound(LL l, LL r, LL x)
{
	if (l > r)
		return true;
	return l <= x && x <= r;
}

struct Eq2
{
	LLL a, b, c;
	Eq2(LLL a = 0, LLL b = 0, LLL c = 0)
		: a(a), b(b), c(c)
	{
		LLL g = __gcd(__gcd(a, b), c);
		a /= g;
		b /= g;
		c /= g;
	}

	vector<LL> rooti(LL l = 1, LL r = -1)
	{
		// dbg(a, b, c);

		vector<LL> res;
		LL delt = b * b - a * c * 4;
		if (delt < 0)
			return res;

		LL dr = sqrti(delt);
		LL num1 = (-b - dr) / (a * 2);
		if (inbound(l, r, num1))
			res.push_back(num1);
		LL num2 = (-b + dr) / (a * 2);
		if (inbound(l, r, num2))
			res.push_back(num2);
		return res;
	}
};

void solve(LLL a, LLL b, LLL c) // keep int sols of eq2(a, b, c)
{
	dbg("solve", (LL)a, (LL)b, (LL)c);
	LLL delta = b * b - a * c * 4;
	if (delta < 0) return;
	LLL dr = sqrti(delta);
	if (dr * dr != delta) return;
	LLL n1 = -b - dr, n2 = -b + dr, A = a * 2;
	if (n1 % A == 0) ++mp[n1 / A];
	if (n2 % A == 0) ++mp[n2 / A];
}

bool finalStage(LLL x)
{
	dbg("finalstage", (LL)x);
	if (e.eval(x) != 0)
		return false;
	mp[x]++;
	LLL a = e.a, b = e.b, c = e.c, d = e.d;
	b += a * x; c += b * x;
	d += c * x;
	solve(a, b, c);
	return true;
}

bool go(LL l, LL r)
{
	dbg("1", l, r);
	if (l > r) return false;
	if (sgn(e.eval(l)) * sgn(e.eval(r)) > 0)
		return false;
	
	dbg(l, r);
	while (l < r - 1)
	{
		LL m = (l + r) >> 1;
		if (sgn(e.eval(l)) * sgn(e.eval(m)) <= 0)
			r = m;
		else
			l = m;
	}
	bool res = finalStage(l);
	if (res)
		return true;
	if (l != r) res = finalStage(r);
	if (res) return true;
	return false;
}

int main(int argc, char const *argv[])
{
	int n;
	LL a, b, c, d;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		LLL g = __gcd(__gcd(a, b), __gcd(c, d));
		a /= g;
		b /= g;
		c /= g;
		d /= g;
		e = Eq3(a, b, c, d); 
		Eq2 s(a * 3, b * 2, c);
		auto minmax = s.rooti(-inf, inf);
		minmax.push_back(-inf - 1);
		minmax.push_back(inf + 1);
		bool flag = false;
		
		sort(minmax.begin(), minmax.end());
		for (auto x : minmax)
		{
			if (finalStage(x))
			{
				flag = true;
				break;
			}
		}
		if (flag) continue;
		for (int i = 0; i < (int)minmax.size() - 1; ++i)
		{
			dbg(i, minmax[i]);
			bool res = go(minmax[i] + 1, minmax[i + 1] - 1);
			if (res) break;
		}
	}

	if (mp.empty()) puts("NO");
	else
	{
		pair<LL, int> p(-1, -1);
		for (const auto pp : mp)
		{
			if (pp.second > p.second)
				p = pp;
		}
		printf("YES\n%lld %d\n", p.first, p.second);
	}
	
	
	
	return 0;
}